package ru.evga.inse.server.gwt.user.client.menu;

import ru.evga.gwt.lib.common.client.place.PlaceImpl;
import ru.evga.gwt.lib.common.client.place.PlaceParamMap;
import ru.evga.inse.server.gwt.user.client.IUserAppFactory;
import ru.evga.inse.server.gwt.user.client.menu.admin.AdminActivityMapper;
import ru.evga.inse.server.gwt.user.client.menu.general.GeneralActivity;
import ru.evga.inse.server.gwt.user.client.menu.realty.RealtyActivity;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;


public class SubMenuActivityMapper
    implements ActivityMapper
{
    private IUserAppFactory m_factory;

    public SubMenuActivityMapper(IUserAppFactory factory)
    {
        m_factory = factory;
    }

    public Activity getActivity(Place place)
    {
        final PlaceParamMap paramMap = PlaceParamMap.makePlaceParamMap((PlaceImpl)place); 
        
        
        MenuProcessor<Activity> processor = new MenuProcessor<Activity>()
        {

            public void handleGeneral()
            {
                setResult(new GeneralActivity(m_factory));
            }

            public void handleRealty()
            {
                setResult(new RealtyActivity(m_factory));
            }

            public void handleForum()
            {
                
            }

            public void handleAdmin()
            {
                setResult(AdminActivityMapper.getInstance().getSubMenuActivity(paramMap, m_factory));
            }
        };
        
        return processor.process(MenuPlaceUtil.getMenuItem(paramMap));
    }
}
